﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DualControl.Controllers;
using DualControl.ControlMeasures.Dtos;
using DualControl.RiskLibrary;
using DualControl.RiskLibrary.Dtos;
using Microsoft.AspNetCore.Mvc;
using X.PagedList;

namespace DualControl.Web.Mvc.Controllers
{
    public class RiskNotificationController : DualControlControllerBase
    {
        private readonly IRiskLibraryAppService _riskLibraryAppService;

        public RiskNotificationController(IRiskLibraryAppService riskLibraryAppService)
        {
            _riskLibraryAppService = riskLibraryAppService;

        }

        public async Task<IActionResult>  Index(int page)
        {
            int pagenumber = page < 1 ? 1 : page;

            GetHSNotificationInput input = new GetHSNotificationInput
            {
                SkipCount = (pagenumber - 1) * AppConsts.DefaultPageSize,
                MaxResultCount = AppConsts.DefaultPageSize
            };

            var result = await _riskLibraryAppService.GetPagedHSControlMeasure(input);

            var PageOfHSControlMeasureListDto = new StaticPagedList<HSNotificationListDto>(result.Items, pagenumber, AppConsts.DefaultPageSize, result.TotalCount);
            //将分页结果放入ViewBag供View使用
            ViewBag.PageOfHSControlMeasureListDto = PageOfHSControlMeasureListDto;

            return View();
        }
    }
}